//
import { createRouter, createWebHistory } from 'vue-router'
import Login from '@/views/Login/index.vue'
import Layout from '@/views/Layout/index.vue'
import Home from '@/views/Home/index.vue'
import Detail from '@/views/Detail/index.vue'
import Cart from '@/views/Cart/index.vue'
import SelectCart from '@/views/SelectCart/index.vue'
import Topay from '@/views/ToPay/index.vue'
import List from '@/views/List/index.vue'
import My from '@/views/My/index.vue'
import UserInfo from '@/views/My/components/UserInfo.vue'
import UserOrder from '@/views/My/components/UserOrder.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
   {
    path:'/',
    component:Layout,
    children:[
      {
        path:'',
        component:Home
      },
      {
        path:'list',
        component:List
      },
      {
        path:"detail/:id",
        component: Detail 
      },{
        path:"cart",
        component:Cart
      },{
        path:'selectCart',
        component:SelectCart
      },{
        path:'topay',
        component:Topay
      } ,{
        path:'my',
        component:My,
        // 三级路由
        children:[
          {
            path:'',
            component:UserInfo
          },
          {
            path:'order',
            component:UserOrder
          }
        ]
      }
    ]
   },
   {
    path:'/login',
    component:Login
   }
  ],
  scrollBehavior(){
    return{
      top:0
    }
  }
})

export default router
